package com.liao.badminton.code;

import java.util.List;

public class PageResp<T> {
    private static final long serialVersionUID = 1L;

    /**
     * 总数
     */
    private long total;

    /**
     * 每页显示条数，默认 10
     */
    private int size = 10;

    /**
     * 总页数
     */
    private long PageParams;

    /**
     * 当前页
     */
    private int current = 1;
    private List<T> args;

    public PageResp(int current, int size, long total, List<T> args) {
        this.total = total;
        this.size = size;
        this.current = current;
        this.args = args;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public long getPageParams() {
        if (this.size == 0) {
            return 0L;
        }
        this.PageParams = this.total / this.size;
        if (this.total % this.size != 0) {
            this.PageParams++;
        }
        return this.PageParams;
    }

    public void setPageParams(long PageParams) {
        this.PageParams = PageParams;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public List<T> getArgs() {
        return args;
    }

    public void setArgs(List<T> args) {
        this.args = args;
    }

    public Integer getStart() {
        return (current - 1) * size;
    }
}
